package com.shareach.http.shop.parameter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.shareach.web.basic.IAskParameter;


public class BizTuanParameter implements IAskParameter {
	/**
	 * 网站拼音
	 */
	public String site;
	/**
	 * 目标网站团购的Id
	 */
	public String tuanId;
    /**
     * 目标url
     */
    public String url;
    public String city;
    public String img;
    public String descr;
    /**
     * 点评Id
     */
    public List<BizTuanShopParameter> shopes;
    /**
     * 截止日期
     */
    public String end;
    /**
     * 折扣
     */
    public Integer discount;
    /**
     * 折后价格
     */
    public Double price;
    /**
     * 原价
     */
    public Double orgPrice;
    /**
     * 标题描述
     */
    public String title;
    
	@SuppressWarnings("unchecked")
	@Override
	public void parseFromMap(HashMap<String, Object> map) {
		if(map.containsKey("site")) this.site = (String)map.get("site");
		if(map.containsKey("tuanId")) this.tuanId = (String)map.get("tuanId");
		if(map.containsKey("city")) this.city = (String)map.get("city");
		if(map.containsKey("url")) this.url = (String)map.get("url");
		if(map.containsKey("img")) this.img = (String)map.get("img");
		if(map.containsKey("descr")) this.descr = (String)map.get("descr");
		if(map.containsKey("end"))this.end = (String)map.get("end");
		if(map.containsKey("discount"))this.discount = (Integer)map.get("discount");
		if(map.containsKey("price"))this.price = (map.get("price") instanceof Integer)?(Integer)map.get("price"):(Double)map.get("price");
		if(map.containsKey("orgPrice"))this.orgPrice = (map.get("orgPrice") instanceof Integer)?(Integer)map.get("orgPrice"):(Double)map.get("orgPrice");//(Double)map.get("orgPrice");
		if(map.containsKey("title"))this.title = (String)map.get("title");
		if(map.containsKey("shopes")){
			this.shopes = new ArrayList<BizTuanShopParameter>();
			List<HashMap<String, Object>> shopesMap = (ArrayList<HashMap<String, Object>>)map.get("shopes");
			for(HashMap<String, Object> item : shopesMap){
				BizTuanShopParameter sp = new BizTuanShopParameter();
				sp.parseFromMap(item);
				shopes.add(sp);
			}
		}
	}
}
